package cn.wolfcode.wolf2w.business.controller;

import cn.wolfcode.wolf2w.common.core.domain.R;
import cn.wolfcode.wolf2w.common.security.annotation.InnerAuth;
import cn.wolfcode.wolf2w.business.api.domain.Region;
import cn.wolfcode.wolf2w.business.query.RegionQuery;
import cn.wolfcode.wolf2w.business.service.IRegionService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * 区域 Controller
 *
 * @author ysc
 * @date 2024-12-17
 */
@Api(value = "热门区域", tags = {"定义当季的热门区域"})
@RestController
@RequestMapping("regions")

@ApiResponses(
        {
                @ApiResponse(code = 200, message = "成功"),
                @ApiResponse(code = 401, message = "未登录"),
                @ApiResponse(code = 403, message = "未授权"),
                @ApiResponse(code = 404, message = "找不到接口"),
                @ApiResponse(code = 400, message = "参数异常"),
                @ApiResponse(code = 500, message = "系统内部异常"),
                @ApiResponse(code = 501, message = "业务异常")
        }
)
public class RegionController {
    @Autowired
    private IRegionService regionService;

    /**
     * 区域详情
     */
    @ApiOperation(value = "详情接口", notes = "查询热门区域详情接口")
    @ApiImplicitParams(
            @ApiImplicitParam(value = "热门区域ID", name = "id", dataType = "Long", required = true, example = "355")
    )
    @GetMapping("/detail/{id}")
    public R<Region> detail(@PathVariable Long id) {
        Region region = regionService.getById(id);
        return R.ok(region);
    }

    /**
     * 区域 列表
     */
    @ApiOperation(value = "分页查询接口", notes = "分页查询热门区域详情接口")
    @GetMapping("/query")
    public R<IPage<Region>> query(RegionQuery qo) {
        IPage<Region> page = regionService.queryPage(qo);
        return R.ok(page);
    }


    /*****************************************对外暴露Fegin接口**********************************************/
    /**
     * Feign 接口
     */
    @GetMapping("/feign/list")
    public R<List<Region>> feignList() {
        return R.ok(regionService.list());
    }

    @InnerAuth
    @GetMapping("/feign/{id}")
    public R<Region> feignGet(@PathVariable Long id) {
        return R.ok(regionService.getById(id));
    }
}
